﻿$(function () {
    $('.roll-qc-parent').css('right', Math.round(($(window).width() - 960) / 2) + 'px');
    $('.roll-qc').css('top', '-156px');
    $('.roll-qc-parent').css('height', '100px');

    $('.roll-qc-parent .rr-action-qc').click(function (e) {
        e.stopPropagation();
        e.preventDefault();

        if ($(this).data('open') == '1') {
            closeQc();
            $(this).data('open', '0');
        } else {
            openQc();
            $(this).data('open', '1');
        }
    });

    $('.qc-pi').click(function () {
        if ($(this).hasClass('qc-pi')) {
            $(this).val('');
            $(this).removeClass('qc-pi');
        }
    });

    $('.qc-ok').click(function (e) {
        e.preventDefault();
        e.stopPropagation();
        $(this).hide();
        $('.qc-complete').show();
        $.ajax({
            type: "POST",
            url: "/Handlers/ApartsService.asmx/AddQuickContact",
            data: "{'phoneNumber': '" + $('input[name=qc-phone]').val() + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json"
        });
    });

    if ($('body').hasClass('withFrontBaner')) {
        //    $('.roll-qc-parent').css('left', (parseInt($('.roll-reservation-parent').css('left')) + $('.roll-reservation').width() + 20) + 'px');
        $('.roll-qc-parent').hide();
    }

});

function openQc() {
    qcEasing = 'easeOutQuint';
    if (typeof (rollReservationEasing) != undefined)
        qcEasing = rollReservationEasing;

    $('.roll-qc-parent').css('height', '');
    $('.roll-qc').animate({
        top: '0px'
    }, 700, qcEasing);
    $('.rr-action-qc').text(language.close.toUpperCase())
}

function closeQc() {
    qcEasing = 'easeOutQuint';
    if (typeof (rollReservationEasing) != undefined)
        qcEasing = rollReservationEasing;

    $('.roll-qc').animate({
        top: '-156px'
    }, 500, qcEasing, function () { $('.roll-qc-parent').height(100); });
    $('.rr-action-qc').text(language.open.toUpperCase());
}
